const express = require('express');
const app = express();

app.all('*', function(req, res, next) {
  res.header('Access-Control-Allow-Origin', "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header('Access-Control-Allow-Credentials', "true");
  res.header("X-Powered-By", ' 3.2.1');
  next();
});

// 注册路由
const userRouter = require('./routes/users');
const checkRouter = require('./routes/checkJWT');
app.use(userRouter);
app.use(checkRouter);

app.listen(5432,()=>{
  console.log('backend run at\n',
      ' http://localhost:5432/\n',
      ' http://127.0.0.1:5432/')
})